package util

import (
	"encoding/json"
	logger "gitee.com/zaper/private-logger"
)

type HttpContext struct{}

type HttpResponseError struct {
	ErrorCode int32       `json:"error_code"`
	ErrorMess interface{} `json:"error_mess"`
}

func NewHttpResponseError(errorCode int32, errorMess interface{}) *HttpResponseError {
	return &HttpResponseError{
		ErrorCode: errorCode,
		ErrorMess: errorMess,
	}
}

func (httpResponseError *HttpResponseError) ToJsonString() string {
	resp, err := json.Marshal(httpResponseError)
	if err != nil {
		logger.Infof("To json fail , Marshal fail , error is %s", err)
		return ""
	}
	return string(resp)
}
